<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "goods".
 *
 * @property int $id
 * @property string $name
 * @property string $price
 * @property int $stock
 * @property string $path
 */
class PeGoods extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'goods';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['price'], 'number'],
            [['stock'], 'integer'],
            [['name'], 'string', 'max' => 20 ,'min'=>5],
            [['path'], 'string', 'max' => 100],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'price' => 'Price',
            'stock' => 'Stock',
            'path' => 'Path',
        ];
    }

    public function AddIndex()
    {
     return $this->save();
        
    }
    public function del($id){
      $customer = PeGoods::findOne($id);
      return $customer->delete();

    }

}
